version: '{build}'
image: Visual Studio 2019
configuration:
- Release
platform: x64
build:
  project: source-code/PD-Loader.sln
  verbosity: minimal
after_build:
- ps: |
    mkdir "$env:TMP/full/patches"
    mkdir "$env:TMP/full/plugins"
    mkdir "$env:TMP/full/plugins/Novidia Shaders"
    mkdir "$env:TMP/full/ram/databank_template"

    cp "$env:APPVEYOR_BUILD_FOLDER/source-code/x64/$env:CONFIGURATION/dnsapi.dll" "$env:TMP/full"
    cp "$env:APPVEYOR_BUILD_FOLDER/source-code/x64/$env:CONFIGURATION/*.dva" "$env:TMP/full/plugins"

    if ( "$env:CONFIGURATION" -imatch "Release" )
    {
      mkdir "$env:TMP/full/plugins/zh-Hans"
      mkdir "$env:TMP/full/plugins/pt-BR"
      mkdir "$env:TMP/full/plugins/it-IT"
      cp "$env:APPVEYOR_BUILD_FOLDER/source-code/data/patches/custom_freeplay_text_example.p" "$env:TMP/full/patches"
      cp "$env:APPVEYOR_BUILD_FOLDER/source-code/x64/$env:CONFIGURATION/zh-Hans/*.dll" "$env:TMP/full/plugins/zh-Hans"
      cp "$env:APPVEYOR_BUILD_FOLDER/source-code/x64/$env:CONFIGURATION/pt-BR/*.dll" "$env:TMP/full/plugins/pt-BR"
      cp "$env:APPVEYOR_BUILD_FOLDER/source-code/x64/$env:CONFIGURATION/it-IT/*.dll" "$env:TMP/full/plugins/it-IT"
    }

    cp "$env:APPVEYOR_BUILD_FOLDER/source-code/data/README - PD Loader.url" "$env:TMP/full"
    cp "$env:APPVEYOR_BUILD_FOLDER/source-code/data/*.sfv" "$env:TMP/full"
    cp "$env:APPVEYOR_BUILD_FOLDER/source-code/data/plugins/*.*" "$env:TMP/full/plugins"
    cp "$env:APPVEYOR_BUILD_FOLDER/source-code/data/plugins/Novidia Shaders/*.*" "$env:TMP/full/plugins/Novidia Shaders"
    cp "$env:APPVEYOR_BUILD_FOLDER/source-code/data/ram/databank_template/*.dat" "$env:TMP/full/ram/databank_template"

    cd "$env:TMP/full"

    7z a "$env:APPVEYOR_BUILD_FOLDER/PD-Loader-$env:CONFIGURATION-AppVeyor-$env:APPVEYOR_REPO_COMMIT.zip" *
    
    rm "$env:TMP/full/plugins/Launcher.dva"
    rm "$env:TMP/full/plugins/CustoMixer.dva"
    rm "$env:TMP/full/plugins/DivaWig.dva"
    rm "$env:TMP/full/plugins/DSCRemote.dva"
    rm "$env:TMP/full/plugins/modpacks" -r -fo
    7z a "$env:APPVEYOR_BUILD_FOLDER/PD-Loader-$env:CONFIGURATION-HardMode-AppVeyor-$env:APPVEYOR_REPO_COMMIT.zip" *
artifacts:
- path: PD-Loader-*.zip
